package cn.fanqinghong.ymcc.feignClients;

import cn.fanqinghong.ymcc.doc.CourseDoc;
import cn.fanqinghong.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * FAN
 * 2022/7/24  15:40
 */
@Component
public class SearchFallbackFactory implements FallbackFactory<CourseSearchFeignClient> {
    @Override
    public CourseSearchFeignClient create(Throwable throwable) {
        return new CourseSearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("课程上架出错！！");
            }

            @Override
            public JSONResult deleteCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("课程下架出错！！");
            }
        };
    }
}
